package com.talos.ums.dal.mysql.socialuser;

import com.talos.framework.common.pojo.PageResult;
import com.talos.framework.mybatis.core.mapper.BaseMapperX;
import com.talos.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.talos.ums.controller.admin.socialuser.vo.UmsSocialUserPageReqVO;
import com.talos.ums.dal.dataobject.socialuser.UmsSocialUserDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 社交用户表 Mapper
 *
 * @author ${table.author}
 */
@Mapper
public interface UmsSocialUserMapper extends BaseMapperX<UmsSocialUserDO> {

    default PageResult<UmsSocialUserDO> selectPage(UmsSocialUserPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UmsSocialUserDO>()
                .eqIfPresent(UmsSocialUserDO::getUserId, reqVO.getUserId())
                .eqIfPresent(UmsSocialUserDO::getUserType, reqVO.getUserType())
                .eqIfPresent(UmsSocialUserDO::getType, reqVO.getType())
                .eqIfPresent(UmsSocialUserDO::getOpenid, reqVO.getOpenid())
                .eqIfPresent(UmsSocialUserDO::getUnionId, reqVO.getUnionId())
                .eqIfPresent(UmsSocialUserDO::getToken, reqVO.getToken())
                .eqIfPresent(UmsSocialUserDO::getRawTokenInfo, reqVO.getRawTokenInfo())
                .likeIfPresent(UmsSocialUserDO::getNickname, reqVO.getNickname())
                .eqIfPresent(UmsSocialUserDO::getAvatar, reqVO.getAvatar())
                .eqIfPresent(UmsSocialUserDO::getRawUserInfo, reqVO.getRawUserInfo())
                .eqIfPresent(UmsSocialUserDO::getCode, reqVO.getCode())
                .eqIfPresent(UmsSocialUserDO::getState, reqVO.getState())
                .eqIfPresent(UmsSocialUserDO::getCreatorCode, reqVO.getCreatorCode())
                .betweenIfPresent(UmsSocialUserDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(UmsSocialUserDO::getModifierCode, reqVO.getModifierCode())
                .betweenIfPresent(UmsSocialUserDO::getModifyTime, reqVO.getModifyTime())
                .eqIfPresent(UmsSocialUserDO::getDeleted, reqVO.getDeleted())
                .eqIfPresent(UmsSocialUserDO::getTenantId, reqVO.getTenantId())
                .orderByDesc(UmsSocialUserDO::getId));
    }

}
